package org.darkforest.model;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.darkforest.common.util.DateUtil;
import org.darkforest.common.util.Page;
import org.darkforest.enums.OrderStatusEnum;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Order extends Page<Order>{
    private Integer orderId;

    @JsonSerialize(using=ToStringSerializer.class)
    private Long orderSn;

    private String orderSns;

    private String paySn;

    private Integer storeId;

    private String storeName;

    private Integer buyerId;

    private String buyerName;

    private String buyerEmail;

    private int addTime;

    private String paymentCode;

    private Integer paymentTime;

    private String paymentName;

    private Integer finnshedTime;

    private BigDecimal goodsAmount;

    private BigDecimal orderAmount;

    private BigDecimal pdAmount;

    private Integer coinAmount;     //增加使用金币数量

    private BigDecimal shippingFee;

    private String evaluationState;

    private String orderState;

    private Integer refundState;

    private Integer lockState;

    private Byte deleteState;

    private BigDecimal refundAmount;

    private Integer delayTime;

    private String orderFrom;

    private String shippingCode;

    private String cancelReason;

    private Integer sellerId;                   //店补卖家编号

    private String startTime;

    private String endTime;

    private Integer direct;  //0，自己 1，直接会员，2，间接会员  用于webchat收入统计

    private Integer isDept;  //是否分佣 0，否，1，是

    private OrderCommon orderCommon = new OrderCommon();

    private Long OrderBatchNumber;

    private Integer buyType;

    public Integer getBuyType() {
        return buyType;
    }

    public void setBuyType(Integer buyType) {
        this.buyType = buyType;
    }

    private List<OrderGoods> orderGoodsList = new ArrayList<OrderGoods>();


    public String getOrderSns() {
        return orderSns;
    }

    public void setOrderSns(String orderSns) {
        this.orderSns = orderSns;
    }

    public Long getOrderBatchNumber() {
        return OrderBatchNumber;
    }

    public void setOrderBatchNumber(Long orderBatchNumber) {
        OrderBatchNumber = orderBatchNumber;
    }

    public OrderCommon getOrderCommon() {
        return orderCommon;
    }

    public void setOrderCommon(OrderCommon orderCommon) {
        this.orderCommon = orderCommon;
    }

    public String getOrderStateDes(){
        return OrderStatusEnum.getTextByValue(Integer.parseInt(this.orderState));
    }

    public String getAddTimeDes(){
        return DateUtil.converMsec2Date(new Long(this.addTime));
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public Integer getSellerId() {
        return sellerId;
    }

    public void setSellerId(Integer sellerId) {
        this.sellerId = sellerId;
    }

    public Integer getCoinAmount() {
        return coinAmount;
    }

    public void setCoinAmount(Integer coinAmount) {
        this.coinAmount = coinAmount;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Long getOrderSn() {
        return orderSn;
    }

    public void setOrderSn(Long orderSn) {
        this.orderSn = orderSn;
    }

    public String getPaySn() {
        return paySn;
    }

    public void setPaySn(String paySn) {
        this.paySn = paySn;
    }

    public Integer getStoreId() {
        return storeId;
    }

    public void setStoreId(Integer storeId) {
        this.storeId = storeId;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName == null ? null : storeName.trim();
    }

    public Integer getBuyerId() {
        return buyerId;
    }

    public void setBuyerId(Integer buyerId) {
        this.buyerId = buyerId;
    }

    public String getBuyerName() {
        return buyerName;
    }

    public void setBuyerName(String buyerName) {
        this.buyerName = buyerName == null ? null : buyerName.trim();
    }

    public String getBuyerEmail() {
        return buyerEmail;
    }

    public void setBuyerEmail(String buyerEmail) {
        this.buyerEmail = buyerEmail == null ? null : buyerEmail.trim();
    }

    
    public int getAddTime() {
		return addTime;
	}

	public void setAddTime(int addTime) {
		this.addTime = addTime;
	}

    public String getPaymentCode() {
        return paymentCode;
    }

    public void setPaymentCode(String paymentCode) {
        this.paymentCode = paymentCode;
    }

    public Integer getPaymentInteger(){
        return Integer.parseInt(paymentCode);
    }

//	public String getPaymentCode() {
//        if(paymentCode==null)
//            return "";
//        if (paymentCode.equals("1"))
//            return "微信";
//        else if (paymentCode.equals("2"))
//            return "支付宝";
//        else if (paymentCode.equals("3"))
//            return "余额支付";
//        else if (paymentCode.equals("4"))
//            return "余额和微信";
//        else
//            return "余额和支付宝";
//    }
//
//    public void setPaymentCode(String paymentCode) {
//        this.paymentCode = paymentCode == null ? null : paymentCode.trim();
//    }

    public Integer getPaymentTime() {
        return paymentTime;
    }

    public void setPaymentTime(Integer paymentTime) {
        this.paymentTime = paymentTime;
    }

    public Integer getFinnshedTime() {
        return finnshedTime;
    }

    public void setFinnshedTime(Integer finnshedTime) {
        this.finnshedTime = finnshedTime;
    }

    public BigDecimal getGoodsAmount() {
        return goodsAmount;
    }

    public void setGoodsAmount(BigDecimal goodsAmount) {
        this.goodsAmount = goodsAmount;
    }

    public BigDecimal getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(BigDecimal orderAmount) {
        this.orderAmount = orderAmount;
    }

    public BigDecimal getPdAmount() {
        return pdAmount;
    }

    public void setPdAmount(BigDecimal pdAmount) {
        this.pdAmount = pdAmount;
    }

    public BigDecimal getShippingFee() {
        return shippingFee;
    }

    public void setShippingFee(BigDecimal shippingFee) {
        this.shippingFee = shippingFee;
    }

    public String getEvaluationState() {
        return evaluationState;
    }

    public void setEvaluationState(String evaluationState) {
        this.evaluationState = evaluationState == null ? null : evaluationState.trim();
    }

    public String getOrderState() {
        return orderState;
    }

    public void setOrderState(String orderState) {
        this.orderState = orderState == null ? null : orderState.trim();
    }

    public Integer getRefundState() {
        return refundState;
    }

    public void setRefundState(Integer refundState) {
        this.refundState = refundState;
    }

    public Integer getLockState() {
        return lockState;
    }

    public void setLockState(Integer lockState) {
        this.lockState = lockState;
    }

    public Byte getDeleteState() {
        return deleteState;
    }

    public void setDeleteState(Byte deleteState) {
        this.deleteState = deleteState;
    }

    public BigDecimal getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(BigDecimal refundAmount) {
        this.refundAmount = refundAmount;
    }

    public Integer getDelayTime() {
        return delayTime;
    }

    public void setDelayTime(Integer delayTime) {
        this.delayTime = delayTime;
    }

    public String getOrderFrom() {
        return orderFrom;
    }

    public void setOrderFrom(String orderFrom) {
        this.orderFrom = orderFrom == null ? null : orderFrom.trim();
    }

    public String getShippingCode() {
        return shippingCode;
    }

    public void setShippingCode(String shippingCode) {
        this.shippingCode = shippingCode == null ? null : shippingCode.trim();
    }

    public String getPaymentName() {

        if(paymentCode==null)
            return "未知";
        if (paymentCode.equals("1"))
            return "微信";
        else if (paymentCode.equals("2"))
            return "余额";
        else if (paymentCode.equals("3"))
            return "领取";
        else if (paymentCode.equals("4"))
            return "余额和微信";
        else
            return "余额和支付宝";
    }

    public void setPaymentName(String paymentName) {
        this.paymentName = paymentName;
    }

    public String getCancelReason() {
        return cancelReason;
    }

    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderId=" + orderId +
                ", orderSn=" + orderSn +
                ", paySn=" + paySn +
                ", storeId=" + storeId +
                ", storeName='" + storeName + '\'' +
                ", buyerId=" + buyerId +
                ", buyerName='" + buyerName + '\'' +
                ", buyerEmail='" + buyerEmail + '\'' +
                ", addTime=" + addTime +
                ", paymentCode='" + paymentCode + '\'' +
                ", paymentTime=" + paymentTime +
                ", paymentName='" + paymentName + '\'' +
                ", finishedTime=" + finnshedTime +
                ", goodsAmount=" + goodsAmount +
                ", orderAmount=" + orderAmount +
                ", pdAmount=" + pdAmount +
                ", coinAmount=" + coinAmount +
                ", shippingFee=" + shippingFee +
                ", evaluationState='" + evaluationState + '\'' +
                ", orderState='" + orderState + '\'' +
                ", refundState=" + refundState +
                ", lockState=" + lockState +
                ", deleteState=" + deleteState +
                ", refundAmount=" + refundAmount +
                ", delayTime=" + delayTime +
                ", orderFrom='" + orderFrom + '\'' +
                ", shippingCode='" + shippingCode + '\'' +
                ", cancelReason='" + cancelReason + '\'' +
                '}';
    }

    public Integer getDirect() {
        return direct;
    }

    public void setDirect(Integer direct) {
        this.direct = direct;
    }

    public Integer getIsDept() {
        return isDept;
    }

    public void setIsDept(Integer isDept) {
        this.isDept = isDept;
    }

    public List<OrderGoods> getOrderGoodsList() {
        return orderGoodsList;
    }

    public void setOrderGoodsList(List<OrderGoods> orderGoodsList) {
        this.orderGoodsList = orderGoodsList;
    }
}